package com.manor.main.adapter;

import android.content.Context;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

/**
 */
public class RankingListPagerAdapter extends FragmentPagerAdapter {

    private static final int PAGE_COUNT = 2;
    private Context mContext;
    private String tabTitles[];
    private CharmListFragment charmListFragment;
    private NouveauRicheFragment nouveauRicheFragment;

    public RankingListPagerAdapter(FragmentManager fm, Context mContext) {
        super(fm);
        this.mContext = mContext;
        tabTitles = new String[]{"魅力榜", "土豪榜"};
    }


    @Override
    public Fragment getItem(int position) {
        switch (position) {
            case 1:
                if (nouveauRicheFragment == null) {
                    nouveauRicheFragment = NouveauRicheFragment.newInstance();
                }
                return nouveauRicheFragment;
            case 0:
            default:
                if (charmListFragment == null) {
                    charmListFragment = CharmListFragment.newInstance();
                }
                return charmListFragment;


        }
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return tabTitles[position];
    }

    @Override
    public int getCount() {
        return PAGE_COUNT;
    }
}
